package com.kmxd.ams.core.util;

import cn.hutool.core.lang.caller.CallerUtil;

/**
 * 调用通用方法
 *
 * @author nickbi
 */
public class AmsCallerUtil extends CallerUtil {
  /**
   * caller 2 callerCaller 3 3Caller 4
   *
   * @param depth
   * @param isFullName
   * @return
   */
  public static String getCallerMethodName(int depth, boolean isFullName) {
    final StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[depth];
    final String methodName = stackTraceElement.getMethodName();
    if (!isFullName) {
      return methodName;
    }

    return stackTraceElement.getClassName() + "." + methodName;
  }

  public static String getCallerName(int depth) {
    return CallerUtil.getCaller(depth).getName();
  }
}
